import { createRouter, createWebHashHistory } from "vue-router";
import routes from "./routes";

const router = createRouter({ 
    history: createWebHashHistory(),
    routes
})

router.afterEach((to) => { 
    if (to.query?.invite) { 
        window.localStorage.setItem(process.env.NFT_APP_INVITE, to.query.invite)
    }
    if (to.meta.auth) { 
        const TOKEN = localStorage.getItem(process.env.VUE_APP_TOKEN)
        if (!TOKEN) { 
            router.push({path: '/login'})
        }
    }
})

export default router